<?php /*a:3:{s:103:"/Users/huangjiapeng/未命名文件夹/git/A3Mall-GITEE/server/app/admin/view/wechat/article/editor.php";i:1636210239;s:93:"/Users/huangjiapeng/未命名文件夹/git/A3Mall-GITEE/server/app/admin/view/main/layout.php";i:1639309502;s:107:"/Users/huangjiapeng/未命名文件夹/git/A3Mall-GITEE/server/app/admin/view/wechat/common/wechat_menu.php";i:1629663074;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>A3Mall | Dashboard</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="/static/system/js/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/system/font/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/system/css/AdminLTE.min.css">
    <link rel="stylesheet" href="/static/system/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="/static/system/js/layui/css/layui.css">
    <link rel="stylesheet" href="/static/system/css/base.css">
    <script src="/static/system/js/jquery/jquery.min.js"></script>
    <script src="/static/system/js/bootstrap/js/bootstrap.min.js"></script>
    <script src="/static/system/js/layui/layui.js"></script>
    <script src="/static/system/js/fastclick/fastclick.js"></script>
    <script src="/static/system/js/adminlte/adminlte.min.js"></script>
    <script src="/static/system/js/jquery-slimscroll/jquery.slimscroll.min.js"></script>
    <script src="/static/system/js/common/common.js"></script>
    <script type="text/javascript">
        $.ajaxSetup({
            contentType:"application/x-www-form-urlencoded;charset=utf-8",
            complete:function(XMLHttpRequest,textStatus){
                var res = XMLHttpRequest.responseText;
                try{
                    var jsonData = JSON.parse(res);
                    if(jsonData.code == -1000){
                        window.location.href = '<?php echo createUrl("login/index"); ?>';
                    }else if(jsonData.code == -999){
                        layer.msg(jsonData.msg,{ icon: 2, time: 5000 },function () {
                            window.history.go(-1);
                        });
                    }
                }catch(e){}
            }
        });
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini fixed">
<div class="wrapper">

    <header class="main-header">

        <!-- Logo -->
        <a href="<?php echo createUrl('platform.index/index'); ?>" class="logo">
            <!-- mini logo for sidebar mini 50x50 pixels -->
            <span class="logo-mini"><b>A3</b></span>
            <!-- logo for regular state and mobile devices -->
            <span class="logo-lg"><b>A3Mall</b></span>
        </a>

        <!-- Header Navbar: style can be found in header.less -->
        <nav class="navbar navbar-static-top">
            <!-- Sidebar toggle button-->
            <div class="navbar-custom-menu navbar-left navbar-list-top">
                <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
                    <span class="sr-only">Toggle navigation</span>
                </a>
                <ul class="nav navbar-nav">
                    <?php if(isset($sidebar['top'])): if(is_array($sidebar['top']) || $sidebar['top'] instanceof \think\Collection || $sidebar['top'] instanceof \think\Paginator): $i = 0; $__LIST__ = $sidebar['top'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$menu): $mod = ($i % 2 );++$i;?>
                        <li class="<?php if($menu['active']): ?>active<?php endif; ?>"><a href="<?php echo htmlentities($menu['url']); ?>"><?php echo htmlentities($menu['name']); ?></a></li>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                    <?php endif; ?>
                </ul>
            </div>
            <!-- Navbar Right Menu -->
            <div class="navbar-custom-menu">
                <ul class="nav navbar-nav">
                    <li><a href="<?php echo url('home/index/index'); ?>" target="_blank"><i class="fa fa-home"></i>&nbsp;网站前台</a></li>
                    <li><a href="<?php echo url('login/logout'); ?>"><i class="fa fa-sign-out"></i>&nbsp;退出</a></li>
                </ul>
            </div>

        </nav>
    </header>
    <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar">
        <!-- sidebar: style can be found in sidebar.less -->
        <section class="sidebar">
            <!-- Sidebar user panel -->
            <div class="user-panel">
                <div class="pull-left image">
                    <img src="/static/system/images/avatar.jpeg" class="img-circle" alt="User Image">
                </div>
                <div class="pull-left info">
                    <p><?php echo session("users.username"); ?></p>
                    <p style="font-size: 12px;"><?php echo session("users.title"); ?></p>
                </div>
            </div>
            <!-- sidebar menu: : style can be found in sidebar.less -->
            <ul class="sidebar-menu" data-widget="tree">
                <li class="header">系统菜单</li>
                <?php if(!empty($sidebar['menu'])): if(is_array($sidebar['menu']) || $sidebar['menu'] instanceof \think\Collection || $sidebar['menu'] instanceof \think\Paginator): $i = 0; $__LIST__ = $sidebar['menu'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$side): $mod = ($i % 2 );++$i;?>
                <li class="treeview<?php if($side['active']): ?> active menu-open<?php endif; ?>">
                    <a href="javascript:;">
                        <i class="<?php echo htmlentities($side['icon']); ?>"></i> <span><?php echo htmlentities($side['name']); ?></span>
                        <span class="pull-right-container">
                            <i class="fa fa-angle-left pull-right"></i>
                        </span>
                    </a>
                    <ul class="treeview-menu">
                        <?php if(is_array($side['children']) || $side['children'] instanceof \think\Collection || $side['children'] instanceof \think\Paginator): $i = 0; $__LIST__ = $side['children'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$children): $mod = ($i % 2 );++$i;?>
                        <li <?php if($children['active']): ?>class="active"<?php endif; ?>>
                        <a href="<?php echo htmlentities($children['url']); ?>"><i class="fa fa-circle-o"></i><?php echo htmlentities($children['name']); ?></a>
                        </li>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                    </ul>
                </li>
                <?php endforeach; endif; else: echo "" ;endif; ?>
                <?php endif; ?>
                <li class="header">联系方式</li>
                <li><a href="http://www.a3-mall.com" target="_blank"><i class="fa fa-circle-o text-yellow"></i> <span>官方网站</span></a></li>
                <li><a href="http://wpa.qq.com/msgrd?v=3&uin=3439167048&site=qq&menu=yes"><i class="fa fa-circle-o text-red"></i> <span>QQ：3439167048</span></a></li>
                <li><a href="https://qm.qq.com/cgi-bin/qm/qr?k=lBxucAil6e6WTlwX0tNvQwpOtfLP2ptd&jump_from=webapi"><i class="fa fa-circle-o text-red"></i> <span>Q群：892150829</span></a></li>
                <li><a href="javascript:;"><i class="fa fa-circle-o text-aqua"></i> <span>手机：18026740326</span></a></li>
            </ul>
        </section>
        <!-- /.sidebar -->
    </aside>

    <div class="content-wrapper clearfix">
        <div class="row content-nav inline-page-box">
    <div class="col-xs-12">
        <ul>
            <li><a href="javascript:;"><i></i>&nbsp;微信管理</a></li>
            <li><a href="javascript:;">公众号</a></li>
        </ul>
    </div>
</div>

<section class="content">
    <div class="row">
        <div class="col-md-3 l-col-md-3">
            <a href="<?php echo createUrl('editor'); ?>" class="btn btn-primary btn-block margin-bottom">添加图片</a>
            <div class="box box-solid">
                <div class="box-header with-border">
                    <h3 class="box-title">菜单</h3>

                    <div class="box-tools">
                        <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
                        </button>
                    </div>
                </div>
                <div class="box-body no-padding">
                    <ul class="nav nav-pills nav-stacked">
                        <ul class="nav nav-pills nav-stacked">
    <?php if(is_array($sidebar['menu']) || $sidebar['menu'] instanceof \think\Collection || $sidebar['menu'] instanceof \think\Paginator): $i = 0; $__LIST__ = $sidebar['menu'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$sidebar): $mod = ($i % 2 );++$i;if(is_array($sidebar['children']) || $sidebar['children'] instanceof \think\Collection || $sidebar['children'] instanceof \think\Paginator): $i = 0; $__LIST__ = $sidebar['children'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$children): $mod = ($i % 2 );++$i;if($children['active']): if(is_array($children['children']) || $children['children'] instanceof \think\Collection || $children['children'] instanceof \think\Paginator): $i = 0; $__LIST__ = $children['children'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$value): $mod = ($i % 2 );++$i;?>
                <li<?php if($value['active']): ?> class="active"<?php endif; ?>><a href="<?php echo htmlentities($value['url']); ?>"><?php echo htmlentities($value['name']); ?></a></li>
                <?php endforeach; endif; else: echo "" ;endif; ?>
            <?php endif; ?>
        <?php endforeach; endif; else: echo "" ;endif; ?>
    <?php endforeach; endif; else: echo "" ;endif; ?>
</ul>
                    </ul>
                </div>

            </div>

        </div>

        <div class="col-md-9 r-col-md-9">
            <div class="layui-fluid">
                <div class="layui-card">

                    <div class="col-md-3">
                        <div class="article-left">
                            <div class="layui-card-body">
                                <div class="ls-box">
                                    <div id="left-wrap"></div>
                                </div>
                                <a class="article-add"><i class="fa fa-plus"></i></a>
                            </div>
                        </div>
                    </div>


                    <div class="col-md-9">
                        <div class="article-right">
                            <section class="content clearfix" style="padding-top: 0;">
                                <div class="layui-editor-box">
                                    <div style="margin-top: 0;" class="layui-tab layui-tab-brief layui-tab-bg layui-tab-content-box">
                                        <ul class="layui-tab-title">
                                            <li class="layui-this">基本信息</li>
                                        </ul>
                                        <form action="" class="layui-form layui-form-pane">
                                            <div class="layui-tab-content">
                                                <div class="layui-tab-item layui-show">

                                                    <div class="layui-form-item">
                                                        <label class="layui-form-label">文章标题</label>
                                                        <div class="layui-input-block">
                                                            <input type="text" name="title" value="" lay-reqtext="请填写文章标题" lay-verify="required" placeholder="请输入文章标题" autocomplete="off" class="layui-input">
                                                        </div>
                                                    </div>

                                                    <div class="layui-form-item">
                                                        <label class="layui-form-label">文章作者</label>
                                                        <div class="layui-input-block">
                                                            <input type="text" name="author" value="" lay-reqtext="请填写文章作者" lay-verify="required" placeholder="请输入文章作者" autocomplete="off" class="layui-input">
                                                        </div>
                                                    </div>

                                                    <div class="layui-form-item clearfix">
                                                        <div class="layui-upload clearfix">
                                                            <button type="button" class="layui-btn layui-bg-light-blue" id="uploadfiy-btn"><i class="layui-icon"></i>上传图片</button>
                                                            <blockquote class="layui-elem-quote layui-quote-nm clearfix" style="margin-top: 10px;">
                                                                预览图：
                                                                <div class="layui-upload-list" id="uploadfiy-list-box">

                                                                </div>
                                                            </blockquote>
                                                        </div>
                                                    </div>

                                                    <div class="layui-form-item">
                                                        <script id="container" style="width:100%;height: 500px;" name="content" type="text/plain"></script>
                                                    </div>

                                                    <div class="layui-form-item data-type">
                                                        <label class="layui-form-label">摘要</label>
                                                        <div class="layui-input-block">
                                                            <textarea class="layui-textarea" name="digest"></textarea>
                                                        </div>
                                                    </div>

                                                    <div class="layui-form-item">
                                                        <label class="layui-form-label">原文链接</label>
                                                        <div class="layui-input-block">
                                                            <input type="text" name="content_source_url" value="" placeholder="请输入原文链接" autocomplete="off" class="layui-input">
                                                        </div>
                                                    </div>

                                                </div>

                                            </div>
                                            <div class="layui-form-item">
                                                <div class="layui-input-block">
                                                    <button class="layui-btn layui-bg-light-blue" lay-filter="layui-submit-filter" lay-submit="">立即提交</button>
                                                    <button class="layui-btn layui-btn-primary" type="reset">重置</button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </section>
                        </div>
                    </div>




                </div>
            </div>
        </div>

    </div>

</section>

<script id="left" type="text/html">

    {{#  layui.each(d, function(index, item){ }}
    <div class="article-item-wrap">
        <div class="article-item" style="background-image:url({{ item.local_url }})">
        <span class="article-item-top">
            <a class="layui-icon dd">&#x1006;</a>
            <!-- a class="layui-icon down">&#xe61a;</a -->
            <!-- a class="layui-icon up">&#xe619;</a -->
        </span>
            <span class="article-title">{{ item.title }}</span>
        </div>
        <hr>
    </div>
    {{#  }); }}
    {{#  if(d.length === 0){ }}
    <div class="article-item-wrap">
        <div class="article-item active" style="background-image:url(/static/images/default.jpg)">
        <span class="article-item-top">
            <a class="layui-icon dd">&#x1006;</a>
            <!-- a class="layui-icon down">&#xe61a;</a -->
            <!-- a class="layui-icon up">&#xe619;</a -->
        </span>
            <span class="article-title">新建图文</span>
        </div>
        <hr>
    </div>
    {{#  } }}

</script>
<script id="images-list-box" type="text/html">
    {{#  layui.each(d.images, function(index, item){ }}
    <div class="uploadfiy-box">
        <input type="hidden" name="attachment_id[]" value="{{ item.id }}">
        <a class="upload-image"><img src="{{ item.path }}"></a>
        <div class="uploadfiy-button">
            <a href="javascript:;" class="n6-insert">插入</a>
            {{#  if(d.local_url.length > 0 && d.local_url == item.path){ }}
            <a href="javascript:;" class="n6-thumb active">封面</a>
            {{#  } else { }}
            <a href="javascript:;" class="n6-thumb">封面</a>
            {{#  } }}
            <a href="javascript:;" class="n6-delete">删除</a>
        </div>
    </div>
    {{#  }); }}
</script>

<script type="text/javascript" src="/static/system/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/static/system/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
UE.getEditor('container').addListener("ready", function (){
    var ue = UE.getEditor('container');
    layui.use(["form", "element","layer","upload","laytpl"], function() {
        var form = layui.form;
        var layer = layui.layer;
        var upload = layui.upload;
        var laytpl = layui.laytpl;

        var data = JSON.parse('<?php echo (isset($data['article']) && ($data['article'] !== '')?$data['article']:"[]"); ?>');
        var pid = '<?php echo htmlentities((isset($data['id']) && ($data['id'] !== '')?$data['id']:"0")); ?>';

        var activeIndex = 0;
        var renderHtml = function (){
            laytpl(document.getElementById("left").innerHTML).render(data, function (html) {
                $("#left-wrap").html(html);
                $(document).find(".article-item").eq(activeIndex).addClass("active");
                $(document).find('[name="title"]').val(data[activeIndex].title);
                $(document).find('[name="author"]').val(data[activeIndex].author);
                $(document).find('.article-item').eq(activeIndex).css("background-image",data[activeIndex].photo);
                UE.getEditor('container').setContent(data[activeIndex].content,false);
                $(document).find('[name="digest"]').val(data[activeIndex].digest);
                $(document).find('[name="content_source_url"]').val(data[activeIndex].content_source_url);
            });
        };

        var renderImage = function (){
            var image = data[activeIndex];
            laytpl(document.getElementById("images-list-box").innerHTML).render(image, function (html) {
                $(".layui-upload-list").html(html);
            });
        };

        $(document).find('[name="title"]').on("input",function (){
            data[activeIndex].title = $(this).val();
            renderHtml();
        });

        $(document).find('[name="author"]').on("input",function (){
            data[activeIndex].author = $(this).val();
            renderHtml();
        });

        $(document).find('[name="content"]').on("input",function (){
            data[activeIndex].content = $(this).val();
            renderHtml();
        });

        UE.getEditor('container').addListener('blur',function(editor){
            data[activeIndex].content = UE.getEditor('container').getContent();
            renderHtml();
        });

        $(document).find('[name="digest"]').on("input",function (){
            data[activeIndex].digest = $(this).val();
            renderHtml();
        });

        $(document).find('[name="content_source_url"]').on("input",function (){
            data[activeIndex].content_source_url = $(this).val();
            renderHtml();
        });

        var i = 0;
        $(document).on("click",".article-add",function (){
            data.push({
                "id": "0",
                "title":"新建图文-"+(i+1),
                "show_cover_pic":1,
                "author": "管理员",
                "local_url": "/static/images/default.jpg",
                "images":[],
                "content": "请填写内容",
                "digest": "",
                "content_source_url": ""
            });

            i++;
            renderHtml();
            renderImage();
        });

        <?php if(!empty($data)): ?>
            renderHtml();
        <?php else: ?>
            $(".article-add").trigger("click");
        <?php endif; ?>


        $(document).on("click",".article-item",function () {
            var index = $(this).index(".article-item");
            activeIndex = index;
            renderHtml();
            renderImage();
        });

        $(document).on("click",".article-item-top",function (e){
            var index = $(this).index(".article-item-top");
            if($(e.target).is(".up")){
                if(index!=0){
                    data[index] = data.splice(index-1, 1, data[index])[0];
                }else{
                    data.push(data.shift());
                }
            }else if($(e.target).is(".down")){
                if(index!=data.length-1){
                    data[index] = data.splice(index+1, 1, data[index])[0];
                }else{
                    data.unshift(data.splice(index,1)[0]);
                }
            }else if($(e.target).is(".dd")){
                if($(".article-item-top").length <= 1){
                    return false;
                }
                data.splice(index,1);
            }else{
                return false;
            }
            var arr = [];
            for(var i in data){
                if(data[i]){
                    arr.push(data[i]);
                }
            }
            data = arr;
            activeIndex = 0;
            renderHtml();
        });

        //多图片上传
        upload.render({
            elem: '#uploadfiy-btn'
            ,url: '<?php echo createUrl("common.uploadfiy/upload"); ?>'
            ,multiple: true
            ,exts: 'jpg|png|gif|bmp|jpeg'
            ,data: {
                module: function (){
                    return "wechat";
                },
                method: function (){
                    return "article";
                }
            }
            ,done: function(res){
                if(!res.code){
                    data[activeIndex].images.push({
                        "id":res.data.id,
                        "path":res.data.src
                    });
                    renderImage();
                }else{
                    layer.msg(res.msg,{ icon : 2 });
                }
            }
        });

        $(document).on("click",".n6-insert",function (){
            var pt = $(this).parent().parent();
            UE.getEditor('container').setContent('<p><img src="'+pt.find("img").attr("src")+'"></p>', true);
            return false;
        });

        $(document).on("click",".n6-thumb",function (){
            if($(this).is(".active")){
                $(this).removeClass("active");
                return false;
            }

            $(".n6-thumb").removeClass("active");
            $(this).addClass("active");
            var pt = $(this).parent().parent();
            data[activeIndex].local_url = pt.find("img").attr("src");
            renderHtml();
            return false;
        });

        $(document).on("click",".n6-delete",function (){
            var index = $(this).index(".n6-delete");
            var pt = $(this).parent().parent();
            $.post('<?php echo createUrl("common.uploadfiy/delete"); ?>',{
                path : pt.find("img").attr("src")
            },function (result){
                if(result.code){
                    data[activeIndex].images.splice(index,1);
                    renderImage();
                    pt.remove();
                }else{
                    layer.msg(result.msg,{ icon : 2 });
                }
            },"json");
            return false;
        });

        form.on('submit(layui-submit-filter)', function (r) {
            var index = layer.load(1, { shade: [0.2,'#fff'] });
            $.post('<?php echo createUrl("editor"); ?>', { pid:pid,post:data }, function (result) {
                layer.close(index);
                if(result.code){
                    layer.msg(result.msg, {
                        time: 0
                        ,btn: ['继续发布', '返回列表']
                        ,yes: function(index){
                            window.location.href = '<?php echo createUrl("editor"); ?>';
                        }
                        ,btn2: function (index, layero){
                            window.location.href = '<?php echo createUrl("index"); ?>';
                        }
                    });
                }else{
                    layer.msg(result.msg,{ icon :2 });
                }
            }, "json");
            return false;
        });
    });
});
</script>
<style type="text/css">
.article-left {
    width: 100%;
    background: #fff;
}
.article-right{
    overflow: hidden;
    width: 100%;
    position: relative;
    display: inline-block;
    background: #fff;
}
.article-left .article-item {
    height: 150px;
    cursor: pointer;
    max-width: 270px;
    overflow: hidden;
    position: relative;
    border: 1px solid #ccc;
    background-size: cover;
    background-position: center center;
}
.article-left .article-item.active {
    border: 1px solid #44b549 !important;
}
.article-left .article-item a {
    color: #fff;
    width: 30px;
    height: 30px;
    float: right;
    font-size: 12px;
    margin-top: -1px;
    line-height: 34px;
    text-align: center;
    margin-right: -1px;
    background-color: rgba(0, 0, 0, .5);
}
.article-left .article-title {
    bottom: 0;
    color: #fff;
    width: 272px;
    display: block;
    padding: 0 5px;
    max-height: 6em;
    overflow: hidden;
    margin-left: -1px;
    position: absolute;
    text-overflow: ellipsis;
    background: rgba(0, 0, 0, .7);
}
.article-item .article-item-top { display: none; }
.article-item:hover .article-item-top {
    display: block;
}
.article-left .article-add {
    color: #999;
    display: block;
    font-size: 22px;
    text-align: center;
    cursor: pointer;
}
</style>




    </div>

    <footer class="main-footer">
        <div class="pull-right hidden-xs">
            <b>Version</b> <?php echo htmlentities(config('version.version')); ?>
        </div>
        <strong>Copyright &copy; 2019-<?php echo date("Y"); ?> <a href="http://www.a3-mall.com">数循通云计算科技有限公司 | A3Mall</a>.</strong> All rights
        reserved.
    </footer>

</div>

</body>
</html>